package com.yonyou.pmclouds.alter.mapper;


import com.yonyou.pmclouds.alter.entity.AlterListViewVO;
import com.yonyou.pmclouds.alter.entity.AlterVO;
import com.yonyou.pmclouds.basecom.dao.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;


public interface AlterMapper extends BaseMapper<AlterVO> {
    @Select("select pk_alter, pk_altercategory, apply_date, creator,  creationtime, billstatus, alter_content  from pm_alter where pk_project = #{pkProject} and dr = 0 order by creationtime desc")
    @ResultType(AlterListViewVO.class)
    AlterListViewVO[] getListViewVOByProject(@Param("pkProject") String pkProject);

    @Select("select pk_alter, pk_altercategory, apply_date, creator,  creationtime, billstatus, alter_content  from pm_alter where pk_alter in (${strIds}) and dr = 0 order by creationtime desc")
    @ResultType(AlterListViewVO.class)
    AlterListViewVO[] getByIds(@Param("strIds") String strIds);

    /**
     * 请注意，这里的code不可使用模块之外传入的属性，避免sql注入
     */
    @Select("select count(*) from pm_alter where ${code} in  (${ids}) and dr = 0 ")
    int getRefByIds(@Param("code") String code, @Param("ids") String ids);


    AlterVO[] queryByCondition(@Param("pkProjects")String[] pkProjects,
                                      @Param("creators") String[] creators,
                                      @Param("startDate") String startDate,
                                      @Param("endDate") String endDate,
                                      @Param("billStatus") int[] billStatus,
                                      @Param("start") int start,
                                      @Param("size") int size);

    int countByCondition(@Param("pkTenant") String pkTenant,
                               @Param("pkProjects")String[] pkProjects,
                               @Param("creators") String[] creators,
                               @Param("startDate") String startDate,
                               @Param("endDate") String endDate,
                               @Param("billStatus") int[] billStatus);

}
